<template>
    <el-container>
        <el-header>
            <div class="right-panel-search">
                <div class="search-input">计划完工</div>
                <el-date-picker v-model="value1" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :size="size" />
                <div class="search-input">客户名称</div>
                <el-select v-model="search.color_type" placeholder="请选择客户名称">
                    <el-option label="主色" :value="1"></el-option>
                    <el-option label="加色" :value="2"></el-option>
                </el-select>
                <div class="search-input">订单号</div>
                <el-input v-model="search.design_num" placeholder="请输入订单号" style="width:10%" />
                <div class="search-input">任务状态</div>
                <el-select v-model="search.color_type" placeholder="请选择">
                    <el-option label="主色" :value="1"></el-option>
                    <el-option label="加色" :value="2"></el-option>
                </el-select>
                <div class="search-input">优先级</div>
                <el-select v-model="search.color_type" placeholder="请选择">
                    <el-option label="主色" :value="1"></el-option>
                    <el-option label="加色" :value="2"></el-option>
                </el-select>
                <el-button type="primary" icon="el-icon-plus" @click="add">查询</el-button>
            </div>
        </el-header>
        <el-header>
            <div>
                <el-button type="primary" icon="el-icon-plus" @click="add">新增</el-button>
                <el-button type="primary" icon="el-icon-plus" @click="add">导出</el-button>
                <el-button type="danger" icon="el-icon-delete" @click="add">批量删除</el-button>
            </div>
        </el-header>
        <el-main class="nopadding">
            <scTable ref="table" :data="tableData" row-key="id" stripe border>
                <el-table-column type="selection" width="30"></el-table-column>
                <el-table-column label="编号" prop="id"  width="50" align="center"></el-table-column>
                <el-table-column label="标记" width="50" align="center"></el-table-column>
                <el-table-column label="任务编号" prop="number" width="100" align="center"></el-table-column>
                <el-table-column label="优先级" prop="priority" width="100" align="center"></el-table-column>
                <el-table-column label="销售订单号" prop="name" width="100" align="center"></el-table-column>
                <el-table-column label="客户名称" prop="name" width="100" align="center"></el-table-column>
                <el-table-column label="商品编号" prop="name" width="100" align="center"></el-table-column>
                <el-table-column label="商品名称" prop="name" width="100" align="center"></el-table-column>
                <el-table-column label="商品规格" prop="name" width="100" align="center"></el-table-column>
                <el-table-column label="客户原始单号" prop="name"  width="100" align="center"></el-table-column>
                <el-table-column label="订购数量" prop="name" width="100" align="center"></el-table-column>
                <el-table-column label="计划完工日期" prop="data" width="100" align="center"></el-table-column>
                <el-table-column label="计划生产数" prop="name" width="100" align="center"></el-table-column>
                <el-table-column label="成品入库" prop="name" width="100" align="center"></el-table-column>
                <el-table-column label="质检报废数" prop="name" width="100" align="center"></el-table-column>
                <el-table-column label="状态" prop="status" width="100" align="center">
                    <template #default="scope">
                        <div v-if="scope.row.status=='未审核'" style="color:#ed5565">{{scope.row.status}}</div>
                        <div v-else style="color:#018052">{{scope.row.status}}</div>
                    </template>
                </el-table-column>
                <el-table-column label="制单人" prop="name" width="100" align="center"></el-table-column>
                <el-table-column label="操作" fixed="right" align="center">
                    <template #default="scope">
                        <el-button-group>
                            <el-button text type="primary" size="small" @click="handleProcess(scope.row)">加工</el-button>
                            <el-button text type="primary" size="small" @click="handleView(scope.row)">查看</el-button>
                            <el-button text type="primary" size="small" @click="table_show(scope.row, scope.$index)">激活</el-button>
                            <el-button text type="primary" size="small" @click="table_edit(scope.row, scope.$index)">修改</el-button>
                            <el-button text type="primary" size="small" @click="table_edit(scope.row, scope.$index)">审核</el-button>
                            <el-popconfirm title="确定作废吗？" @confirm="table_cancel(scope.row, scope.$index)">
                                <template #reference>
                                    <el-button text type="primary" size="small">作废</el-button>
                                </template>
                            </el-popconfirm>
                            <el-popconfirm title="确定删除吗？" @confirm="table_del(scope.row, scope.$index)">
                                <template #reference>
                                    <el-button text type="danger" size="small">删除</el-button>
                                </template>
                            </el-popconfirm>
                        </el-button-group>
                    </template>
                </el-table-column>
            </scTable>
        </el-main>
    </el-container>
</template>

<script>

export default {
	name: 'user',
	data() {
		return {
			dialog: {
				save: false
			},
			groupFilterText: '',
			group: [],
            search: {
				supplier_id: "",
				custom_id: "",
                order_no:"",
                factory_art_no:"",
                design_num:"",
			},
			tableData: [
                {
                id: 0,
                date: "2016-05-03",
                name: "名称1",
                priority: "无",
                status: "未审核",
                data: "2020-09-11",
                number: "12343",
                },
                {
                id: 1,
                date: "2016-05-02",
                name: "名称2",
                priority: "无",
                status: "未审核",
                data: "2020-09-11",
                number: "23132",
                },
                {
                id: 2,
                date: "2016-05-04",
                name: "名称3",
                priority: "无",
                status: "未审核",
                data: "2020-09-11",
                number: "33231",
                },
                {
                id: 3,
                date: "2016-05-01",
                name: "名称4",
                priority: "无",
                status: "未审核",
                data: "2020-09-11",
                number: "43124",
                },
            ],
		}
	},
	watch: {
		groupFilterText(val) {
			this.$refs.group.filter(val);
		}
	},
	mounted() {
	},
	methods: {
        //添加
		add() {
			this.dialog.save = true
			this.$nextTick(() => {
				this.$refs.saveDialog.open('add')
			})
		},
		//编辑
		table_edit(row) {
			this.dialog.save = true;
			this.$nextTick(() => {
				this.$refs.saveDialog.open("edit").setData(row);
			});
		},
		//查看
		table_show(row) {
			this.dialog.save = true;
			this.$nextTick(() => {
				this.$refs.saveDialog.open("show").setData(row);
			});
		},
		//删除
		async table_del(row, index) {
			var reqData = { id: row.id };
			var res = await this.$API.develop.edition.delete.post(reqData);
			if (res.code == 1) {
				//这里选择刷新整个表格 OR 插入/编辑现有表格数据
				this.$refs.table.tableData.splice(index, 1);
				this.$message.success("删除成功");
			} else {
				this.$alert(res.message, "提示", { type: "error" });
			}
		},
        async table_cancel(row, index) {
			var reqData = { id: row.id };
			var res = await this.$API.develop.edition.cancel.post(reqData);
			if (res.code == 1) {
				//这里选择刷新整个表格 OR 插入/编辑现有表格数据
				this.$refs.table.tableData.splice(index, 1);
				this.$message.success("取消成功");
			} else {
				this.$alert(res.message, "提示", { type: "error" });
			}
		},
		//搜索
		upsearch() {
			this.$refs.table.upData(this.search)
		},
        //本地更新数据
		handleSuccess(data, mode) {
			if (mode == "add") {
				this.$refs.table.refresh();
			} else if (mode == "edit") {
				this.$refs.table.refresh();
			}
		},
	}
}
</script>

<style lang="scss">
.search-input {
	width: auto;
	font-size: 14px;
}
.day{
    display: flex;
    justify-content: center;
}
.shopInfo{
    display: flex;
    align-items: center;
    justify-content: center;
    .right{
        margin-left: 5px;
        text-align: start;
    }
}
.img{
    width: 100px;
    height: 100px;
    margin-right: 5px;
}
</style>
